//
//  CenterWebViewController.m
//  yigou
//
//  Created by 秦乾龙 on 17/2/20.
//  Copyright © 2017年 hanyiwang. All rights reserved.
//

#import "CenterWebViewController.h"

@interface CenterWebViewController ()<UIWebViewDelegate>
@property (nonatomic,retain)UIWebView *webView;
@end

@implementation CenterWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    UIBarButtonItem *backBtn = [ViewFactory makeNavigationBack:self action:@selector(goPop)];
    self.navigationItem.leftBarButtonItem = backBtn;
//    self.navigationItem.titleView = [ViewFactory makeNavigationTitle:@"我的订单"];
    self.title = _titleStr;
    
    self.webView = [[UIWebView alloc]init];
    self.webView.frame = CGRectMake(0, 0, ScreenW, ScreenH);
    [self.view addSubview:self.webView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [ViewFactory setNavigationWhite:self];
    
    self.webView.delegate = self;
    [self.webView setUserInteractionEnabled:YES];//是否支持交互
    [self.webView setScalesPageToFit:YES];//自动缩放以适应屏幕
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]];
    DYLog(@"url==%@",self.url);
}

- (void)goPop {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)webViewDidStartLoad:(UIWebView *)webView {
    [ViewFactory showLoadingEnableTouch];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [ViewFactory dismissLoading];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    [ViewFactory showErrorStrMsg:@"加载失败！"];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
